package com.example.sport.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class webconfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")//所有访问路径都可以跨域
                .allowedOrigins("Http://localhost:8080","null")//跨域来源
                .allowedMethods("GET","POST","PUT","OPTIONS","DELETE")//允许跨域的方法
                .allowCredentials(true)//允许携带信息
                .maxAge(3600);//最大响应时间
    }
}
